<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="static/css/add.css">

</head>

<body>
{#    <ul class="content">#}
{#        <li><span>学科</span> <select name="subject" id=""></select></li>#}

{#        <li class="questionType"><span>题型</span>#}
{#            <ul class="radio">#}
{#                <li><label for="radio"><input type="radio" name="questionType" id="radio" value="radio"> <label for="radio" id="radioText">单选</label></label>#}
{#                </li>#}
{#                <li><label for="checkbox"><input type="radio" name="questionType" id="checkbox" value="checkbox"><label for="checkbox" id="checkboxText">多选</label></label>#}
{#                </li>#}
{#                <li><label for="short-answer"><input type="radio" name="questionType" id="short-answer" value="short-answer"><label for="short-answer" id="short-answerText">简答</label></label>#}
{#                </li>#}
{#            <input >#}
{##}
{#                <input>#}
{#            </ul>#}
{#        </li>#}
{#        <li><button>上传</button><span class="timer"></span></li>#}

        <form class="myForm">

        <input type="text" id="equipment_name" name="equipment_name" value="equipment_name"  required>
        <br><br>

        <input type="text" id="price" name="price" value="price" required>
        <br><br>


        <input type="text" id="configuration" name="configuration" value="configuration" required>
        <br><br>



        <input type="text" id="supplier" name="supplier" value="supplier" required>
        <br><br>


        <input type="text" id="appearance_date" name="appearance_date" value="appearance_date" required>
        <br><br>


        <input type="text" id="laboratory_name" name="laboratory_name" value="laboratory_name" required>
        <br><br>


        <input type="text" id="num" name="num" value="num" required>
        <br><br>





        <button type="button" class="mybutton">提交</button>
    </form>





{#    </ul>#}

</body>
<script src="static/lib/jQuerymini.js"></script>
<script src="static/js/baseAPI.js"></script>
<script src="static/js/utils.js"></script>
<script src="static/js/add.js"></script>
<script>

 document.querySelectorAll('.mybutton').forEach(function(button) {
        button.addEventListener('click', function() {
            let equipment_name = document.getElementById("equipment_name").value;
          let price = document.getElementById("price").value;
          let configuration = document.getElementById("configuration").value;
          let supplier = document.getElementById("supplier").value;
          let appearance_date = document.getElementById("appearance_date").value;
          let laboratory_name = document.getElementById("laboratory_name").value;
          let num = document.getElementById("num").value;
          console.log(num)
            let u={
                "equipment_name":equipment_name,
                "price":price,
                "configuration":configuration,
                "supplier":supplier,
                "appearance_date":appearance_date,
                "laboratory_name":laboratory_name,
                "num":num
            }
             async  function addd() {
                 console.log("进入了注册")
                     try {
                         let res =  await jqAjax('POST', '/equipment/insert', JSON.stringify(u))
                         console.log(res)
                         if (res.msg=="插入成功"){
                              window.location.href = '/index?'+'index=1'+'&page=1&per_page=10&level='+localStorage.getItem("level")
                         }else {
                             alert("失败")
                         }

                         //baseAPI里的函数传参
                         // console.log('点击登录try');
                         // console.log('token:' + res.token);
                         // localStorage.setItem('token', res.token);
                         // $(".uname").val(''); //登录进去之后把用户名密码删掉
                        //跳转到主页面

                     } catch (error) {
                         console.log('catch');
                         $(".uname").val('');
                         $(".psw").val('');
                         alert('错误');
                     }
                 }



            addd()


            alert('调用')

            {#var sequenceId = this.getAttribute('data-sequence-id');#}

       {#window.location.href = '/index?'+'index=1'+'&page=1&per_page=10&level='+localStorage.getItem("level")#}

            // 调用修改函数或执行其他操作，传递序列ID
            // Edit(sequenceId); // 假设您有一个Edit函数
            alert('修改功能尚未实现，序列ID: ' + sequenceId);
        });

    });

</script>


</html>